package com.ruibang.glass.produce.controller.yl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruibang.glass.produce.domain.req.CommonTrendChartReq;
import com.ruibang.glass.produce.domain.req.DefectAnalysisReq;
import com.ruibang.glass.produce.domain.resp.DefectDepthBarChartResp;
import com.ruibang.glass.produce.entity.DefectDepthAnalysis;
import com.ruibang.glass.produce.service.DefectDepthAnalysisService;
import com.teaming.cloud.framework2.common.model.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;


/**
 * <p>
 * 缺陷深度数据分析 前端控制器
 * </p>
 *
 * @author songJinKang
 * @since 2024-04-27
 */
@RestController
@RequestMapping("/api/produce/defect/depth/analysis")
@Api(value = "缺陷深度数据分析控制器", tags = {"缺陷深度数据分析接口"})
public class DefectDepthAnalysisController {

    @Autowired
    private DefectDepthAnalysisService defectDepthAnalysisService;

    @PostMapping("/pageQuery")
    @ApiOperation(value = "分页列表查询缺陷深度数据分析", notes = "分页列表查询缺陷大小数据分析")
    public ResultBody<IPage<DefectDepthAnalysis>> pageQuery(@RequestBody DefectAnalysisReq defectAnalysisReq) {
        return ResultBody.success(defectDepthAnalysisService.pageQuery(defectAnalysisReq));
    }

    @GetMapping("/getById/{id}")
    @ApiOperation(value = "获取缺陷深度数据分析", notes = "获取缺陷大小数据分析")
    public ResultBody getById(@PathVariable(value = "id") String id) {
        return ResultBody.success(defectDepthAnalysisService.getById(id));
    }

    @DeleteMapping("/deleteById/{id}")
    @ApiOperation(value = "通过ID删除缺陷深度数据分析", notes = "通过ID删除缺陷大小数据分析")
    public ResultBody delete(@PathVariable(value = "id") String id) {
        defectDepthAnalysisService.removeById(id);
        return ResultBody.success();
    }

    @PutMapping("/update")
    @ApiOperation(value = "修改缺陷深度数据分析", notes = "修改缺陷大小数据分析")
    public ResultBody updateById(@RequestBody DefectDepthAnalysis defectDepthAnalysis) {
        defectDepthAnalysisService.updateById(defectDepthAnalysis);
        return ResultBody.success();
    }


    /**
     * 图形
     */
    @PostMapping("/curveRateChart")
    @ApiOperation(value = "曲线占比图", notes = "曲线占比图")
    public ResultBody curveRateChart(@RequestBody CommonTrendChartReq commonTrendChartReq) {
        return ResultBody.success(defectDepthAnalysisService.curveRateChart(commonTrendChartReq));
    }

    @PostMapping("/pieRateChart")
    @ApiOperation(value = "饼状占比图", notes = "饼状占比图")
    public ResultBody pieRateChart(@RequestBody CommonTrendChartReq commonTrendChartReq) {
        return ResultBody.success(defectDepthAnalysisService.pieRateChart(commonTrendChartReq));
    }

    @PostMapping("/defectChart")
    @ApiOperation(value = "缺陷图", notes = "缺陷图")
    public ResultBody defectChart(@RequestBody DefectAnalysisReq defectAnalysisReq) {
        return ResultBody.success(defectDepthAnalysisService.defectChart(defectAnalysisReq));
    }

    @PostMapping("/barChart")
    @ApiOperation(value = "柱状图", notes = "柱状图")
    public ResultBody<DefectDepthBarChartResp> barChart(@RequestBody @Valid DefectAnalysisReq defectAnalysisReq) {
        return ResultBody.success(defectDepthAnalysisService.barChart(defectAnalysisReq));
    }
}
